<template>
<div align="center">
  <el-button type="warning"  @click="changUserId"
             size="medium"
             style="margin-left: 800px;"
             plain>切换用户</el-button>当前用户：{{this.queryForm.userId}}
  <el-table
      :data="tableData"
      style="width: 100%">
    <el-table-column
        prop="dealTime"
        label="成交时间"
        width="180">
    </el-table-column>
    <el-table-column
        prop="stoclName"
        label="股票名称"
        width="180">
    </el-table-column>
    <el-table-column
        prop="stockCode"
        width="180"
        label="股票代码">
    </el-table-column>
    <el-table-column
        prop="dealPrice"
        width="180"
        label="成交价格（元）">
    </el-table-column>
    <el-table-column
        prop="dealNum"
        label="成交数量（股）"
        width="180">
    </el-table-column>
    <el-table-column
        prop="dealMoney"
        width="180"
        label="成交金额">
    </el-table-column>
    <el-table-column
        prop="direction"
        label="方向"
        width="180">
    </el-table-column>
  </el-table>

  <el-pagination
      background
      :current-page="queryForm.pageNum"
      :page-size="queryForm.pageSize"
      layout="prev, pager, next"
      @change="toNewPage"
      :total="total">
  </el-pagination>
</div>
</template>

<script>
export default {
  name: "HistoryDeal",
  data(){
  return{
    tableData:[],
    queryForm:{
      userId:1,
      pageNum:1,
      pageSize:3,
    },
    total:0,
  }
  },
  created() {
    this.getDealList();
  },
  methods:{
    toNewPage(newPage){
      this.queryForm.pageNum=newPage;
      this.getDealList();
    },
    getDealList(){
      this.queryForm.haveId=this.queryForm.userId;
      this.axios.post("http://localhost:8182/stock/getHistoryDealList",this.queryForm).then(r=>{
        this.tableData=r.data.data.list;
        this.total=r.data.data.total;
      })
      this.queryForm.pageNum=1;
    },
    changUserId(){
      if(this.queryForm.userId==1){
        this.queryForm.userId=4;
      }else {
        this.queryForm.userId=1;
      }
      this.getDealList();
    }
  },

}
</script>

<style scoped>

</style>